import Vue from 'vue'
import Router from 'vue-router'
import Login from '@/components/Login'
import Menu from '@/components/Menu'
import Welcome from '@/components/Welcome'
import Home from '../components/Home'
import UserList from '../components/UserList'
import RoleManager from '../components/RoleManager'
Vue.use(Router)

const originalPush = Router.prototype.push
Router.prototype.push = function push(location) {
   return originalPush.call(this, location).catch(err => err)
}


export default new Router({
  mode: 'history',
  routes: [
    {
      path: '/login',
      name: 'Login',
      component: Login
    },
    {
      path:'/',
      redirect:'/login'
    },
    {
      path:'/home',
      component:Home,
      redirect:'/home/welcome',
      children:[
        {
          path:'welcome',
          component:Welcome
        },
        {
          path:'userList',
          component:UserList
        },
        {
          path:'role',
          component:RoleManager
        },
        {
          path:'menu',
          component:Menu
        }
      ]
    }
  ]
});
